//
//  SISSHousingProjectFirstView.m
//  SISSAPP
//
//  Created by 袁应荣 on 2018/10/18.
//  Copyright © 2018年 优房网. All rights reserved.
//

#import "SISSHousingProjectFirstView.h"

@interface SISSHousingProjectFirstView ()

@property (weak, nonatomic) UILabel *buildingNameLabel;
@property (weak, nonatomic) UILabel *propertyTypeLabel;
@property (weak, nonatomic) UILabel *buildingAddressLabel;
@property (weak, nonatomic) UIButton *locationButton;

@end
@implementation SISSHousingProjectFirstView

- (void)setBuildingName:(NSString *)buildingName {
    _buildingName = buildingName;
    self.buildingNameLabel.text = buildingName;
}

- (void)setPropertyType:(NSString *)propertyType {
    _propertyType = propertyType;
    self.propertyTypeLabel.text = propertyType;
}

- (void)setBuildingAddress:(NSString *)buildingAddress {
    _buildingAddress = buildingAddress;
    self.buildingAddressLabel.text = buildingAddress;
}

- (void)locationButtonClickAction {
    
    if ([self.delegate respondsToSelector:@selector(locationButtonClickAction)]) {
        [self.delegate locationButtonClickAction];
    }
}

- (void)initUI {
    [super initUI];
    
    UILabel *buildingNameLabel = [UILabel yyr_labelWithText:@"--" fontSize:18 textColor:MAIN_TEXT_COLOR];
    [self addSubview:buildingNameLabel];
    self.buildingNameLabel = buildingNameLabel;
    
    UILabel *propertyTypeLabel = [UILabel yyr_labelWithText:@"--" fontSize:11 textColor:SECONDARY_TEXT_COLOR];
    [self addSubview:propertyTypeLabel];
    self.propertyTypeLabel = propertyTypeLabel;
    
    UILabel *buildingAddressLabel = [UILabel yyr_labelWithText:@"--" fontSize:11 textColor:SECONDARY_TEXT_COLOR];
    [self addSubview:buildingAddressLabel];
    self.buildingAddressLabel = buildingAddressLabel;
    
    UIButton *locationButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [locationButton setImage:[UIImage imageNamed:@"map"] forState:UIControlStateNormal];
    [locationButton addTarget:self action:@selector(locationButtonClickAction) forControlEvents:UIControlEventTouchUpInside];
//    [self addSubview:locationButton];
//    self.locationButton = locationButton;
}

- (void)initConstraint {
    [super initConstraint];
    
    WeakSelf
    [self.buildingNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.equalTo(weakSelf).offset(2 * globelMargin);
    }];
    
    [self.propertyTypeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(weakSelf.buildingNameLabel);
        make.left.equalTo(weakSelf.buildingNameLabel.mas_right).offset(2 * globelMargin);
    }];
    
    [self.buildingAddressLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.buildingNameLabel);
        make.top.equalTo(weakSelf.buildingNameLabel.mas_bottom).offset(2 * globelMargin);
        make.bottom.equalTo(weakSelf).offset(-2 * globelMargin);
    }];
    
//    [self.locationButton mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.centerY.equalTo(weakSelf);
//        make.right.equalTo(weakSelf).offset(-3 * globelMargin);
//    }];
}

@end
